<?php
include ("includes/header.php");
include ("includes/connection.php");
include ("includes/login.php");
include ("includes/registreInicial.php");
include ("./includes/iniciaSessio.php");
?>

<body>
	<?php
	include ("includes/contentHeader.php");
	?>
	<!--contingut 1-->
	<div class="container">
		<section class="row-fluid">
			<!--fons gris-->
			<div class="span7">
				<form name="registre" id="registre" action="registreInsert.php"  method="post" class="form-horizontal">
					<fieldset>
						<legend>
							Registre de Nou Usuari
						</legend>
						<?php 
						if(isset($_SESSION["username"])){
	$alias=$_SESSION["username"];
	
	$sql="SELECT * FROM usuari where alias ='$alias'";

	$res=mysql_query($sql);
	if (!$res) {
	$missatge = 'Consulta Invalida: ' . mysql_error() . "\n";
	$missatge .= 'Consulta SQL: ' . $sql;
	}
	if ($row=mysql_fetch_array($res)){
						?>
						<div class="control-group">
							<label class="control-label" class="control-label"  for="alias">Alias:</label>
							<div class="controls">
								<input class="input-medium" name="nik" type="text" value="<?php echo $row['alias']?>"/>
								<span class="help-inline"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label"  for="password">Contrasenya:</label>
							<div class="controls">
								<input class="input-medium" name="pass" type="password" value="<?php echo $row['contrasenya']?>"/>
								<span class="help-inline"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label"  for="password2">Repeteix Contrasenya:</label>
							<div class="controls">
								<input class="input-medium" name="pass2" type="password"  />
								<span class="help-inline"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label"  for="email">email:</label>
							<div class="controls">
								<input class="input-medium" name="email" type="text" value="<?php echo $row['email']?>"/>
								<span class="help-inline"></span>
							</div>
						</div>
						
		<?php }}else{ ?>
						
						<div class="control-group">
							<label class="control-label" class="control-label"  for="alias">Alias:</label>
							<div class="controls">
								<input class="input-medium" name="nik" type="text" value=""/>
								<span class="help-inline"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label"  for="password">Contrasenya:</label>
							<div class="controls">
								<input class="input-medium" name="pass" type="password" value=""/>
								<span class="help-inline"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label"  for="password2">Repeteix Contrasenya:</label>
							<div class="controls">
								<input class="input-medium" name="pass2" type="password"  />
								<span class="help-inline"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label"  for="email">email:</label>
							<div class="controls">
								<input class="input-medium" name="email" type="text" value=""/>
								<span class="help-inline"></span>
							</div>
						</div>
						<?php }
						//Actualitzen dades del nou usuari que ha inciat sessió?>
					<div class="control-group">
							<label class="control-label" class="control-label"  for="nom">Nom:</label>
							<div class="controls">
								<input class="input-medium" name="nom" type="text" />
								<span class="help-inline"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label"  for="cognom1">Primer Cognom:</label>
							<div class="controls">
								<input class="input-medium" name="cognom1" type="text" />
								<span class="help-inline"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label"  for="cognom2">Segon Cognom:</label>
							<div class="controls">
								<input class="input-medium" name="cognom2" type="text" />
								<span class="help-inline"></span>
							</div>
						</div>
						
						<div class="control-group">
							<label class="control-label"  for="sexe">Sexe:</label>
							<div class="controls">
								<select name="sexe" id="select"  class="input-medium">
									<option value=""></option>
									<option value="home">Home</option>
									<option value="dona">Dona</option>
								</select>
								<span class="help-inline"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label"  for="dia_neix">Data de naixement:</label>
							<div class="controls">
								<input type="text"  name="data" class="input-medium" id="dp1">
								<span class="help-inline"></span>
							</div>
						</div>
						
						<div class="control-group">
							<label class="control-label"  for="biografia">Biografia: (Opcional)</label>
							<div class="controls">
								<textarea rows="5" cols="50" name="biografia" ></textarea>
							</div>
						</div>
						</br></br>
						<button class="enviarFrm btn" name="insertregistre" type="button" value="Enviar" >
							Enviar
						</button>
				
					
					</fieldset>
				</form>
			</div>
			<div class="span4">
				<img src="images/registro2.png" width=300 height=300 border=2 alt="Comparteix coche">
			</div>
			<!-- fi fons gris-->
		</section>
	</div>
	<!-- fi contingut 1-->
	
	<?php
	
	include ("includes/footer.php");
	?>
